Python (programming language)
part 32/106 · 174.3 KB total
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Python uses arbitrary-precision arithmetic for all integer operations. The Decimal type/class in the decimal module provides decimal floating-point numbers to a pre-defined arbitrary precision with several rounding modes.cite-ref-autont-88-116-0[113] The Fraction class in the fractions module provides arbitrary precision for rational numbers.cite-ref-117[114]
Function syntax
Functions are created in Python by using the def keyword. A function is defined similarly to how it is called, by first providing the function name and then the required parameters. Here is an example of a function that prints its inputs:
def printer(input1, input2="already there"):
print(input1)
print(input2)
printer("hello")
# Example output:
# hello
# already there
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────